import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import Home from '../views/admin/Home.vue'
import ServiceManagement from "@/views/admin/ServiceManagement.vue";
import UserManagement from "@/views/admin/UserManagement.vue";
import ClientHome from "@/views/client/Home.vue";
import WorkerHome from "@/views/worker/Home.vue";
import ApplicationManagement from "@/views/admin/ApplicationManagement.vue";
import WorkerManagement from "@/views/admin/WorkerManagement.vue";


const routes = [
    {
        path: '/',
        redirect: '/login'  // 将根路径重定向到登录页
    },
    {
        path: '/login',
        name: 'Login',
        component: Login,
        meta: {
            title: '登录',
            requiresAuth: false  // 不需要验证就能访问
        }
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },
    {
        path: '/admin',
        name: 'Home',
        component: Home,
        meta: { requiresAuth: true }
    },
    {
        path: '/admin/service-management',
        name: 'ServiceManagement',
        component: ServiceManagement
    },
    {
        path: '/admin/user-management',
        name: 'UserManagement',
        component: UserManagement
    },
    {
        path: '/admin/application-management',
        name: 'ApplicationManagement',
        component: ApplicationManagement
    },
    {
        path: '/client',
        name: 'ClientHome',
        component: ClientHome
    },
    {
        path: '/worker',
        name: 'WorkerHome',
        component: WorkerHome
    },
    {
        path: '/admin/worker-management',
        name: 'WorkerManagement',
        component: WorkerManagement
    },
    // 其他路由...
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router
